Learn R Programming

bnlearn (version 0.6)

graph generation tools: Generate an empty or random graph

Description

Generate an empty or random graph from a given set of nodes.

Usage

empty.graph(nodes)
  random.graph(nodes, prob = 0.5)

Arguments

nodes
a vector of character strings, the labels of the nodes.
prob
a numeric value, the probability of connecting a node to another node with higher ordering.

Value

  • Both empty.graph and random.graph return an object of class bn.

Examples

Run this code
empty.graph(LETTERS[1:8])
#
#  Bayesian network learned via Conditional Independence methods
#
#  model:
#    [H][G][F][E][D][C][B][A] 
#  nodes:                                 8 
#  arcs:                                  0 
#    undirected arcs:                     0 
#    directed arcs:                       0 
#  average markov blanket size:           0.00 
#  average neighbourhood size:            0.00 
#  average branching factor:              0.00 
#
#  learning algorithm:                    random/generated
#  conditional independence test:         mutual information 
#  alpha threshold:                       0.05 
#  tests used in the learning procedure:  0 
#
random.graph(LETTERS[1:8])
# <insert the description of a random graph here>
plot(random.graph(LETTERS[1:8]))
plot(random.graph(LETTERS[1:8], prob = 0.2))

Run the code above in your browser using DataLab